
package com.netease.xone.widget.tabview;

import android.content.Context;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.view.View;
import android.widget.TextView;

import com.netease.xone.R;

public class TabInfoDetail extends AbsTabView {
    private SparseArray<TextView> mArray;

    public TabInfoDetail(Context context) {
        super(context);
    }

    public TabInfoDetail(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public int getTabCount() {
        return 3;
    }

    @Override
    public int getTabDividerStyle() {
        return DIVIDER_MIDDLE;
    }

    @Override
    public int getTabDividerResource() {
        return R.drawable.bg_comment_tab_divider;
    }

    @Override
    public View getTabView(int index) {
        TextView tv = (TextView)View.inflate(mContext, R.layout.test_view_information_comment_tab,
                null);
        tv.setClickable(true);
        setText(tv, index, 0);
        
        if (null == mArray) {
            mArray = new SparseArray<TextView>();
        }
        mArray.put(index, tv);
        return tv;
    }

    public void setText(int index, int count) {
        TextView tv = mArray.get(index);
        setText(tv, index, count);
    }
    
    private void setText(TextView tv, int index, int count) {
        if (index == 0) {
            tv.setText(getResources().getString(R.string.infodetail_type_comment, count));
        } else if (index == 1) {
            tv.setText(getResources().getString(R.string.infodetail_type_forward, count));
        } else if (index == 2) {
            tv.setText(getResources().getString(R.string.infodetail_type_praise, count));
        }
    }
}
